from django.urls import path
from . import views

urlpatterns = [
    # 合同管理
    path('contracts/', views.contract_list, name='contract_list'),
    path('contracts/<int:pk>/', views.contract_detail, name='contract_detail'),

    # 租赁申请
    # 新增的创建租赁申请路由 - 移到前面避免被通配符路由捕获
    path('leasing-applications/add/', views.create_leasing_application, name='create_leasing_application'),
    # 新增的提交合同路由
    path('leasing-applications/submit-contract/', views.submit_leasing_contract, name='submit_leasing_contract'),
    # 新增的当前用户租赁申请列表路由
    path('my-leasing-applications/', views.current_user_leasing_applications, name='current_user_leasing_applications'),
    # 新增的我的房源路由
    path('my-housing/', views.my_housing, name='my_housing'),
    path('my-housing/<int:pk>/', views.my_housing_detail, name='my_housing_detail'),
    # 用户可用单元列表
    path('user-available-units/', views.user_available_units, name='user_available_units'),
    # 通用租赁申请路由
    path('leasing-applications/', views.leasing_application_list, name='leasing_application_list'),
    path('leasing-applications/<str:pk>/', views.leasing_application_detail, name='leasing_application_detail'),
    path('leasing-applications/<str:pk>/approve/', views.approve_leasing_application,
         name='approve_leasing_application'),
    # 新增的租赁申请取消路由
    path('leasing-applications/<int:pk>/cancel/', views.cancel_leasing_application, name='cancel_leasing_application'),

    # 装修备案
    # 新增的装修备案路由 - 移到前面避免被通配符路由捕获
    path('decoration-applications/add/', views.create_decoration_application, name='create_decoration_application'),
    path('my-decoration-applications/', views.current_user_decoration_applications, name='current_user_decoration_applications'),
    # 通用装修备案路由
    path('decoration-applications/', views.decoration_application_list, name='decoration_application_list'),
    path('decoration-applications/<int:pk>/', views.decoration_application_detail,
         name='decoration_application_detail'),
    path('decoration-applications/<int:pk>/approve/', views.approve_decoration_application,
         name='approve_decoration_application'),

    # 设备维保
    path('device-maintenance/add/', views.create_device_maintenance, name='create_device_maintenance'),
    path('my-device-maintenance/', views.current_user_device_maintenance_list, name='current_user_device_maintenance_list'),
    path('device-maintenance/', views.device_maintenance_list, name='device_maintenance_list'),
    path('device-maintenance/<int:pk>/', views.device_maintenance_detail, name='device_maintenance_detail'),

    # 车位租赁申请
    path('parking-applications/add/', views.create_parking_application, name='create_parking_application'),
    path('available-parking-spaces/', views.available_parking_spaces, name='available_parking_spaces'),
    path('admin/parking-applications/', views.admin_parking_application_list, name='admin_parking_application_list'),
    path('admin/parking-applications/<int:pk>/approve/', views.approve_parking_application, name='approve_parking_application'),
    path('admin/parking-applications/<int:pk>/reject/', views.reject_parking_application, name='reject_parking_application'),
    path('parking-applications/', views.parking_application_list, name='parking_application_list'),
    path('parking-applications/<int:pk>/', views.parking_application_detail, name='parking_application_detail'),
    path('parking-applications/<int:pk>/cancel/', views.cancel_parking_application, name='cancel_parking_application'),
    path('parking-applications/<int:pk>/submit-contract/', views.submit_parking_contract, name='submit_parking_contract'),

    # 物业报修
    path('repairs/', views.repair_list, name='repair_list'),
    path('repairs/<int:pk>/', views.repair_detail, name='repair_detail'),
    path('repair/<int:pk>/status/', views.update_repair_status, name='update_repair_status'),
    path('repair/<int:pk>/record/', views.add_repair_record, name='add_repair_record'),

    # 保洁预约
    # 新增的创建预约路由 - 与前端代码匹配
    path('cleaning-bookings/add/', views.create_cleaning_booking, name='create_cleaning_booking'),
    # 新增的当前用户保洁预约列表路由
    path('my-cleaning-bookings/', views.current_user_cleaning_booking_list, name='current_user_cleaning_booking_list'),
    path('cleaning-bookings/', views.cleaning_booking_list, name='cleaning_booking_list'),
    path('cleaning-bookings/<int:pk>/', views.cleaning_booking_detail, name='cleaning_booking_detail'),
    path('cleaning/<int:pk>/status/', views.update_cleaning_status, name='update_cleaning_status'),
    path('cleaning/<int:pk>/record/', views.add_cleaning_record, name='add_cleaning_record'),

    # 访客预约
    path('visitor-appointments/', views.visitor_appointment_list, name='visitor_appointment_list'),
    path('visitor-appointments/<int:pk>/', views.visitor_appointment_detail, name='visitor_appointment_detail'),
    path('my-visitor-appointments/', views.my_visitor_appointments, name='my_visitor_appointments'),
    path('companies-for-visitor/', views.companies_for_visitor, name='companies_for_visitor'),

    # 送水服务
    # 新增的创建送水服务路由
    path('water-deliveries/add/', views.create_water_delivery, name='create_water_delivery'),
    # 新增的当前用户送水服务列表路由
    path('my-water-deliveries/', views.current_user_water_delivery_list, name='current_user_water_delivery_list'),
    path('water-deliveries/', views.water_delivery_list, name='water_delivery_list'),
    path('water-deliveries/<int:pk>/', views.water_delivery_detail, name='water_delivery_detail'),
    path('water/<int:pk>/status/', views.update_water_status, name='update_water_status'),
    path('water/<int:pk>/record/', views.add_water_record, name='add_water_record'),

    # Dashboard / Tickets Statistics
    path('tickets/pending-count/', views.get_pending_ticket_count, name='get_pending_ticket_count'),
    path('tickets/type-stats/', views.get_ticket_type_stats, name='get_ticket_type_stats'),
    path('tickets/latest/', views.get_latest_tickets, name='get_latest_tickets'),
    path('stats/', views.get_task_stats, name='get_task_stats'),

    # 工单详情接口
    path('repair/<int:pk>/', views.get_repair_detail, name='get_repair_detail'),
    path('cleaning/<int:pk>/', views.get_cleaning_detail, name='get_cleaning_detail'),
    path('water/<int:pk>/', views.get_water_detail, name='get_water_detail'),

    # 员工工作台接口
    path('staff/tasks/todo', views.get_staff_todo_tasks, name='get_staff_todo_tasks'),
    path('staff/tasks/available', views.get_staff_available_tasks, name='get_staff_available_tasks'),
    path('staff/tasks/completed', views.get_staff_completed_tasks, name='get_staff_completed_tasks'),
    path('staff/performance', views.get_staff_performance, name='get_staff_performance'),
    path('staff/tasks/distribution', views.get_staff_task_distribution, name='get_staff_task_distribution'),
    path('staff/tasks/weekly-stats', views.get_staff_weekly_stats, name='get_staff_weekly_stats'),

    # 临时停车
    path('temporary-parking/', views.temporary_parking_list, name='temporary_parking_list'),
    path('temporary-parking/<int:pk>/', views.temporary_parking_detail, name='temporary_parking_detail'),
    path('vehicles/by-plate/<str:plate_number>/', views.get_vehicle_by_plate, name='get_vehicle_by_plate'),
] 